OSPF的cost计算

您所在的位置:网站首页 what is he like能问外貌吗 OSPF的cost计算

OSPF的cost计算

2024-04-18 16:26| 来源: 网络整理| 查看: 265

众所周知,ospf cost=refefence bandwith/bandwith,默认的 ospf的参考带宽是100000k,即,100M的链路的cost是1,大于100M的cost也都是1.ospf的cost到底是怎么计算的?比如,一条链路有2个端口,是按哪个端口的值来计算的,还是2个端口的共同影响了cost计算过程,下面的实验将对这个问题做阐述。

1、cost到底是怎么计算的 如图,首先我们把所有路由器的所有端口s口bandwidth都改成10000,lookback口都改成100000,然后在R4上看R3上l0的路由,sh ip ro os的输出如下 R4(config-router)#do sh ip ro os O       192.168.100.3 [110/11] via 172.16.34.1, 00:00:06, Serial1/2 第一步,我们在R3上把2号端口的band改成100000,等更新完成SPF重新计算后,输出如下 R4(config-router)#do sh ip ro os O       192.168.100.3 [110/11] via 172.16.34.1, 00:00:06,  说明一条链路的对端的端口不会影响本路由器上路由条目的cost计算。 第二步,在R4的1号端口的ip band改成100000,观察路由表输出如下: R4(config-router)#do sh ip ro os O       192.168.100.3 [110/2] via 172.16.34.1, 00:00:01, Serial1/2 OK,说明只有在本地端口的bandwidth才会影响COST的计算,

那要是在跨多路由器的环境下呢? 思路:cost是累计叠加的,而叠加之前,还是以计算cost的路由器的本地端口的band来计算出分段cost。因此,在一条复杂链路上,计算COST应该根据整条链路上靠近要计算路由器的那些端口的bandwidth,我给他他个定义,就称这里端口为“上游端口”吧,在此case中,假设(R1-R4之间的链路断开)要手工预先计算R1上l0的路由条目在R4的路由表里的cost,那R2,R3,R4的1号端口,都是上游端口,我们可以根据这些端口的bandwidth来计算出分段cost,然后叠加。

题外话:链路的端口bandwidth不同的情况很少出现,只是在手工出现这个情况是,就可以按照这个方法进行一些规划、设计。

2、关于命令auto-cost reference-bandwidth bandwidth R4(config-router)#auto-cost reference-bandwidth 1000000                                              ^ R4(config-router)#do sh ip ro os      172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks O       172.16.23.0/30 [110/20] via 172.16.34.1, 00:00:04, Serial1/2 O IA    172.16.12.0/30 [110/20] via 172.16.14.1, 00:00:04, Serial1/0      192.168.100.0/32 is subnetted, 4 subnets O IA    192.168.100.1 [110/11] via 172.16.14.1, 00:00:04, Serial1/0 O       192.168.100.2 [110/21] via 172.16.34.1, 00:00:04, Serial1/2 O       192.168.100.3 [110/11] via 172.16.34.1, 00:00:04, Serial1/2 R4(config-router)#auto-cost reference-bandwidth 1000000    % OSPF: Reference bandwidth is changed.          Please ensure reference bandwidth is consistent across all routers----------------------------注意这一行提示,显然此命只在本地有效,不会影响到其他neighour. R4(config-router)#do sh ip ro os      172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks O       172.16.23.0/30 [110/65545] via 172.16.34.1, 00:00:07, Serial1/2 O IA    172.16.12.0/30 [110/65545] via 172.16.14.1, 00:00:07, Serial1/0      192.168.100.0/32 is subnetted, 4 subnets O IA    192.168.100.1 [110/65536] via 172.16.14.1, 00:00:07, Serial1/0 O       192.168.100.2 [110/65546] via 172.16.34.1, 00:00:07, Serial1/2 O       192.168.100.3 [110/65536]  -------------------------------------R3上查看路由输出,无变换 R3(config-if)#do sh ip ro os      172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks O IA    172.16.12.0/30 [110/20] via 172.16.23.1, 00:00:26, Serial1/0 O       172.16.14.0/30 [110/65536] via 172.16.34.2, 00:00:26, Serial1/2      192.168.100.0/32 is subnetted, 4 subnets O       192.168.100.4 [110/2] via 172.16.34.2, 00:00:26, Serial1/2 O IA    192.168.100.1 [110/21] via 172.16.23.1, 00:00:26, Serial1/0 O       192.168.100.2 [110/11] via 172.16.23.1, 00:00:26, Serial1/0



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3